package icu.yougan.youganblogbackend.mapper;

import icu.yougan.youganblogbackend.model.Category;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface CategoryMapper {
    
    @Select("SELECT * FROM category ORDER BY id ASC")
    List<Category> selectList();
    
    @Select("SELECT * FROM category WHERE id = #{id}")
    Category selectById(Integer id);
    
    @Insert("INSERT INTO category (name) VALUES (#{name})")
    @Options(useGeneratedKeys = true, keyProperty = "id")
    void insert(Category category);
    
    @Update("UPDATE category SET name = #{name} WHERE id = #{id}")
    void update(Category category);
    
    @Delete("DELETE FROM category WHERE id = #{id}")
    void deleteById(Integer id);
} 